<?php 
if (isset($message)) {
?>
<fieldset>
<?php
echo '<legend>' . $status . '</legend>' . "\n";
echo '<p>Subject: ' . $message[0] . '</p>' . "\n";
echo '<p>Body:</p>' . "\n";
echo '<div>' . "\n";
echo $markdown->parse($message[1]);
echo '</div>' . "\n";
if (isset($errors)) {
	echo '<pre>';
	print_r($errors);
	echo '</pre>';
}
?>
</fieldset>
<?php
}
if (isset($to)) {
?>
<fieldset>
<legend>To:</legend>
<ul>
<?php
  foreach($to as $person) {
    echo '<li>' . $person . '</li>' . "\n";
  }
?>
</ul>
</fieldset>
<?php
}
$url = '/members/messenger';
if ($more) {
	$url .= '/' . $more;
}

?>
<form id='mailform' method='post' action='<?=$html->url($url); ?>'>
<fieldset>
<legend>Send Mass Email</legend>
<?=$form->input('Member.auth_type',array('options'=>$send, 'label'=>'To', 'value' => $this->data['Member']['auth_type']));?>
<?=$form->input('Member.votes', array('label' => 'who have a vote', 'type'=>'checkbox'));?>
<?=$form->input('Member.volunteer', array('label' => 'who are volunteers', 'type'=>'checkbox'));?></p>
<?=$form->input('Member.hasBasket', array('label' => 'who have an invoice open', 'type'=>'checkbox'));?>
<?=$form->input('Member.unpaid', array('label' => 'whose membership is unpaid (not current)', 'type'=>'checkbox'));?>
<?=$form->input('Member.testMode', array('label' => 'Test Mode (doesn\'t send)', 'type'=>'checkbox'));?>

<?=$form->input('Message.subject',array('size'=>50));?>
<?=$form->input('Message.body',array('rows'=>10,'cols'=>50));?>
<?=$form->submit('Preview',array('name'=>'data[submit]'));?></p>
<?php 
if ($more && ($more > 1)) {
	echo '<p>Click Send to send the next 25. (will auto-send in 7 seconds)</p>';
	echo '<input type="hidden" name="data[submit]" value="Send" />';
	echo '<script><!--
		function timeoutForm() {
			setTimeout(\'$("mailform").submit()\',7000);
		}
		Event.observe(window,"load",timeoutForm,false);
	--></script>
	';
}	
?>
<p><?=$form->submit('Send',array('name'=>'data[submit]'));?></p>
</fieldset>
</form>
